#include<iostream>
#include<string>
using namespace std;

void dfs(string a, string b) {
    if (a.length() == 0 || b.length() == 0)
        return;
    char temp = a[0];
    int location = b.find(temp);
    string lb = b.substr(0, location);
    string rb = b.substr(location+1, b.length());
    string la = a.substr(1, lb.length());
    string ra = a.substr(lb.length()+1, a.length());
    dfs(la, lb);
    dfs(ra, rb);
    cout << temp;
}

int main() {
    string pre, mid;
    cin >> pre >> mid;
    dfs(pre, mid);
    return 0;
}